package com.itheima.a01;

import org.springframework.util.AntPathMatcher;

/**
 * 路径规则匹配测试用例
 */
public class AntPathMatcherDemo {
    public static void main(String[] args) {
        AntPathMatcher antPathMatcher = new AntPathMatcher();
        String rule = """
                The mapping matches URLs using the following rules:\s
                ? matches one character
                * matches zero or more characters
                ** matches zero or more directories in a path
                {spring:[a-z]+} matches the regexp [a-z]+ as a path variable named "spring"                
                """;
        String str = """
                com/t?st.jsp — matches com/test.jsp but also com/tast.jsp or com/txst.jsp
                com/*.jsp — matches all .jsp files in the com directory
                         com/**/test.jsp — matches all test.jsp files underneath the com path
                        org/springframework/**/*.jsp — matches all .jsp files underneath the org/springframework path \s
                """;
        System.out.println(""" 
                antPathMatcher.match("com/t?st.jsp", "com/test.jsp")==>> 
                """+antPathMatcher.match("com/t?st.jsp", "com/test.jsp"));//true
        System.out.println(""" 
                antPathMatcher.match("com/**/test.jsp", "com/test.jsp")==>> 
                """+antPathMatcher.match("com/**/test.jsp", "com/test.jsp"));//true
        System.out.println(""" 
                antPathMatcher.match("com/**/test.jsp", "com/aaa/bbb/test.jsp")==>> 
                """+antPathMatcher.match("com/**/test.jsp", "com/aaa/bbb/test.jsp"));//true
        System.out.println(""" 
                antPathMatcher.match("com/**/test.jsp", "com/ccc/test.jsp")==>> 
                """+antPathMatcher.match("com/**/test.jsp", "com/ccc/test.jsp"));//true
    }
}
